function thousandSeparator (n: number): string {
  const arr = String(n).split('')
  let count = 0
  let result: string[] = []
  for (let i = arr.length - 1; i >= 0; i--) {
    result.unshift(arr[i])
    count++
    if (count === 3 && i) {
      count = 0
      result.unshift('.')
    }
  }
  return result.join('')
}

export default function () {
  console.log(thousandSeparator(123456789))
}
